package game.games.rpg;

import game.util.Util;

import java.util.HashMap;
import java.util.Map;

public class AttributedObject
{
    private Map<String, String> attributes = new HashMap<>();
    
    protected final String getAttribute(String key)
    {
        return attributes.get(key);
    }
    
    protected final void setAttribute(String key, String value)
    {
        attributes.put(key, value);
    }
    
    protected final <T> T getAttribute(String key, Class<T> clazz)
    {
        String value = attributes.get(key);
        return Util.toObject(value, clazz);
    }
    
    protected final void setAttribute(String key, Object value)
    {
        setAttribute(key, Util.toString(value));
    }
    
    public String getName()
    {
        return getAttribute("name");
    }
    
    public void setName(String name)
    {
        setAttribute("name", name);
    }
    
    public String getInfo()
    {
        return getAttribute("info");
    }
    
    public void setInfo(String info)
    {
        setAttribute("info", info);
    }
}
